﻿using AutoMapper;

using BCVP.Net8.Model;
using BCVP.Net8.Model.Models;
using BCVP.Net8.Model.ViwModels;

namespace BCVP.Net8.Extensions.AutoMapper
{
    public class CustomProfile : Profile
    {
        /// <summary>
        /// 配置构造函数，用来创建关系映射
        /// </summary>
        public CustomProfile()
        {
            CreateMap<SysUserInfo, SysUserInfoViewModel>()
                .ForMember(a => a.UserName, o => o.MapFrom(d => d.Name));
            CreateMap<SysUserInfoViewModel, SysUserInfo>()
                .ForMember(a => a.Name, o => o.MapFrom(d => d.UserName));

            CreateMap<Role, RoleViewModel>()
                .ForMember(a => a.RoleName, o => o.MapFrom(d => d.Name));
            CreateMap<RoleViewModel, Role>()
                .ForMember(a => a.Name, o => o.MapFrom(d => d.RoleName));

            CreateMap<Book, BookViewModel>();
            CreateMap<BookViewModel, Book>();

            CreateMap<AccessTrendLog, AccessTrendLogViewModel>();
            CreateMap<AccessTrendLogViewModel, AccessTrendLog>();

            CreateMap<AuditSqlLog, AuditSqlLogVoiewModel>();
            CreateMap<AuditSqlLogVoiewModel, AuditSqlLog>();

            CreateMap<WordTestTable, WordTestTableViewModel>();
            CreateMap<WordTestTableViewModel, WordTestTable>();
        }
    }
}
